<template>
	<view>
		<swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000">
			<swiper-item v-for="(item, index) in goodsDetail.pics" @click="preview(index)">
				<image :src="item.pics_mid"></image>
			</swiper-item>
		</swiper>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				goodsDetail: {}
			};
		},
		onLoad(options) {
			const { goods_id } = options
			this.getGoodsDetail(goods_id)
		},
		methods: {
			async getGoodsDetail(goods_id) {
				const { data: res } = await uni.$http.get('/api/public/v1/goods/detail', {goods_id})
				if(res.meta.status !== 200) return uni.$showMsg()
				this.goodsDetail = res.message
			},
			preview(index) {
				uni.previewImage({
					current: index,
					urls: this.goodsDetail.pics.map(item => item.pics_big)
				})
			}
		}
	}
</script>

<style lang="scss">
swiper {
	height: 750rpx;
	image {
		width: 100%;
		height: 100%;
	}
}
</style>
